﻿using SqlMapper;
using SqlMapper.Serializers;
using System;
using System.Collections.Specialized;
using System.IO;
using System.Xml;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string resource = "CfgFiles/SqlMappers.config";
            var doc = new XmlDocument();
            string _applicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            doc.Load(Path.Combine(_applicationBase, resource));

            //XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            //nsmgr.AddNamespace("abcdefg", "NoteHelper.Test");
            XmlNodeList nodes = doc.GetElementsByTagName("select");

            var node = nodes[0];
            var select = SelectDeSerializer.Deserialize(nodes[0]);
            var nvc = new NameValueCollection();
            nvc.Add("FullName", "abc");
            nvc.Add("ObjectID", null);
            nvc.Add("Description", "czx");
            var sql = SqlBuilder.Build(select, nvc);
            Console.WriteLine(sql);
            
            var str = "abc${FullName}123";
            Console.WriteLine(NodeUtils.ParsePropertyTokens(str, nvc));

            Console.ReadKey();
        }
    }
}
